package com.it.myh;

/**
 * @Description: // 类说明，在创建类时要填写
 * @ClassName: Ev_0204_04    // 类名，会自动填充
 * @Author: MYH          // 创建者
 * @Date: 2023/2/4 20:55   // 时间
 * @Version: 1.0     // 版本
 */
public class Ev_0204_04 {

    public static void main(String[] args) {
        String str = "abcdefg";
        //System.out.println(str.substring(2,6));
        String reverse = reverse(str, 2, 6);
        String destStr = str.substring(0,2) + reverse + str.substring(6);
        System.out.println(destStr);
    }
    public static String reverse(String s, int start, int end){

        String str = s.substring(start, end);
        char[] chars = str.toCharArray();
        char[] destChar = new char[chars.length];
        int flag = 0;
        for (int i = chars.length - 1 ;i >= 0 ; i--) {
            destChar[flag] = chars[i];
            flag++;
        }
        String destStr = new String(destChar);
        return destStr;
    }
}
